﻿Public Class TcTest
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'GetUserGroups("gary.pronych@gmail.com")
        'GetUserRoles("gary.pronych@gmail.com")
        GetXmlUserRoles(2100)
        'AddUser()
        'CreateTCUser(4690)
        'AddRole(4690)

    End Sub

    Private Sub CreateTCUser(UserId As Integer)
        Dim nmember As NENAData.NENAMember.NENAMember = New NENAData.NENAMember.NENAMember
        nmember.CreateTelligentCommunityUser(4690)

    End Sub

    Private Sub AddRole(UserId As Integer)
        Dim x As New NENAData.NENAMember.TcMembership()

        Dim ef As New NENAData.NENAMember.Ef()
        Dim efMember As NENAData.EF.Member = ef.GetMember(UserId)
        x.AddUserToRole(efMember.CS_UserID, TelligentCommunity.Roles.Current_Member)
    End Sub
    Private Function GetUserId(Email As String) As Integer
        Dim x As New NENAData.NENAMember.TcXml()
        Dim UserId As Integer
        Return x.GetUserId(Email)
        'Response.Write(UserId)

    End Function

    Private Sub GetUserGroups(Email As String)
        Dim x As New NENAData.NENAMember.TcMembership()
        Dim xml As String
        xml = x.GetUserGroups(GetUserId(Email))
        Response.Write(xml)

    End Sub
    Private Sub GetUserRoles(Email As String)
        Dim x As New NENAData.NENAMember.TcMembership()
        Dim xml As String
        xml = x.GetUserRoles(GetUserId(Email))
        Response.Write(xml)

    End Sub
    Private Sub GetXmlUserRoles(UserId As Integer)
        Dim x As New NENAData.NENAMember.TcXml()
        Dim xml = x.GetUserRoles(UserId)

        For Each role In xml
            Response.Write(role.ToString())
        Next


    End Sub

    Private Sub GetGroups()
        Dim x As New NENAData.NENAMember.TcMembership()
        Dim xml As String
        xml = x.GetGroups()
        Response.Write(xml)
    End Sub

    Private Sub GetUser()
        Dim x As New NENAData.NENAMember.TcMembership()
        Dim xml As String
        xml = x.GetUser("gary.pronych@gmail.com")
        Response.Write(xml)
    End Sub

    Private Sub AddUser()
        Dim ef As New NENAData.NENAMember.Ef()
        Dim efMember As NENAData.EF.Member = ef.GetMember(4690)

        Dim x As New NENAData.NENAMember.TcMembership()
        'x.AddUser(efMember)

        Dim UserId As Integer = GetUserId(efMember.EmailAddress)

        Dim r As New TelligentCommunity.Roles()
        'hardcoded to current_member
        x.AddUserToRole(UserId, "7")
    End Sub

End Class